package com.jdf.database;

import java.sql.*;

public class AccesoDB {

    public Connection cn = null;
    private final static String DRIVER_MYSQL = "com.mysql.jdbc.Driver";
    private final static String URL_MYSQL = "jdbc:mysql://localhost/gstrans";
    private final static String USER_MYSQL = "root";
    private final static String PASS_MYSQL = "mysql";

    public Connection conectar() throws SQLException {

        try {
            // conexión a MySQL
            Class.forName(DRIVER_MYSQL);
            cn = DriverManager.getConnection(URL_MYSQL, USER_MYSQL, PASS_MYSQL);
            System.out.println("Conectado correctamente...! ");

        } catch (Exception ex) {
            System.out.println("Error en la Conexion: " + ex.toString());
        }

        return cn;
    }
}
